package cn.huiyunche.base.service.interfaces.impl;

import cn.huiyunche.base.service.interfaces.CWaybillAttachService;
import cn.huiyunche.base.service.mappers.CWaybillAttachMapper;
import cn.huiyunche.base.service.model.CWaybillAttach;
import cn.huiyunche.base.service.model.CWaybillAttachExample;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LYN on 9/11/16.
 */
@Service
public class CWaybillAttachServiceImpl implements CWaybillAttachService {

    private static final Logger LOGGER = LoggerFactory.getLogger(CWaybillAttachServiceImpl.class);

    @Autowired
    private CWaybillAttachMapper cWaybillAttachMapper;


    @Override
    public List<CWaybillAttach> getByWaybillid(Long waybillid, int type, List<Integer> attachType) {
        LOGGER.info("getByWaybillid param : {}, {}, {}", waybillid, type, attachType);
        CWaybillAttachExample cWaybillAttachExample = new CWaybillAttachExample();
        CWaybillAttachExample.Criteria criteria = cWaybillAttachExample.createCriteria().andWaybillIdEqualTo(waybillid).andCategoryEqualTo(type);
        if (CollectionUtils.isNotEmpty(attachType)) {
            criteria.andTypeIn(attachType);
        }
        return cWaybillAttachMapper.selectByExample(cWaybillAttachExample);
    }
}
